import request from '@/utils/request'

// 列表
export function getArticleList(type, pageNum, pageSize) {
    return request(({
        url: '/article/list',
        method: 'get',
        params: {pageNum: pageNum, pageSize: pageSize, type: type}
    }))
}

export function getArticle(id) {
    return request(({
        url: '/article/' + id,
        method: 'get',
        headers: {
            Authorization: localStorage.getItem('Authorization')
        }
    }))
}

export function addArticle(dto) {
    return request(({
        url: '/article/add',
        method: 'post',
        data: dto,
        headers: {
            Authorization: localStorage.getItem('Authorization')
        }
    }))
}

export function getRecommendArticles(id) {
    return request({
        url: '/article/recommend',
        method: 'get',
        headers: {
            Authorization: localStorage.getItem('Authorization'),
        },
        params: {
            topicId: id
        }
    })
}

export function deleteArticle(id) {
    return request({
        url: '/article/delete',
        method: 'get',
        headers: {
            Authorization: localStorage.getItem('Authorization'),
        },
        params: {
            id: id
        }
    })
}